<?php
/**
 * Created by PhpStorm.
 * User: cc
 * Date: 2023/10/31
 * Time: 2:40 PM
 */

namespace app\zyhsapi\controller\v1;

use think\Controller;
use think\Log;

class PushNotify extends Controller
{
    public function huawei()
    {
        $data = $this->request->param();
        foreach ($data['statuses'] as $item)
        {
            if ($item['biTag'])
            {
                [$thingType, $pushId] = explode('_', $item['biTag']);

                $d = [
                    'thing_type' => $thingType,
                    'push_id' => $pushId,
                    'requestId' => $item['requestId'],
                    'status' => $item['status'],
                    'regid' => $item['token'],
                ];
                // 记录日志
                Log::write($d, '5_flog_push_return', true);
            }
        }
    }

    public function oppo()
    {

        $data = $this->request->param();
//            Log::write('oppo推送回调回执信息' . json_encode($data, true), 'log', true);
        foreach ($data as $item)
        {
            if (isset($item['param']) && $item['param'])
            {
                [$thingType, $pushId] = explode('_', $item['param']);

                $d = [
                    'thing_type' => $thingType,
                    'push_id' => $pushId,
                    'appId' => $item['appId'],
                    'messageId' => $item['messageId'],
                    'eventType' => $item['eventType'],
                    'regids' => "'" . $item['registrationIds'] . "'",
                ];
                // 记录日志
                Log::write($d, '2_flog_push_return', true);
            }
        }
    }

    public function vivo()
    {

        $data = $this->request->param();
        $data = json_encode($data, true);
//            Log::write('Vivo推送回执信息：' . $data);
    }
}
